<?php

class Account_Form_PasswordChange extends Zend_Form
{
	public function init()
	{
		parent::init();

        // Set the method for the display form to POST
		$this
			->setAction('')
			->setMethod('post')
		;

		$stripSlashesFilter = new Euso_Filter_StripSlashes();

		// Create and configure password element
		$password = new Zend_Form_Element_Password('password');
		$password
			->setLabel('Current password:')
			->setRequired(true)
			->addFilter($stripSlashesFilter)
			->addFilter('StringTrim')
			->addValidator('StringLength', false, array(6,20))
			->setAttrib('size', 36)
		;
		$this->addElement($password);

		// Create and configure password element
		$pwdnew = new Zend_Form_Element_Password('password_new');
		$pwdnew
			->setLabel('New password:')
			->setRequired(true)
			->addFilter($stripSlashesFilter)
			->addFilter('StringTrim')
			->addValidator('StringLength', false, array(6,20))
			->setAttrib('size', 36)
		;
		$this->addElement($pwdnew);

		// Create and configure confirm password element
		$pwdnew2 = new Zend_Form_Element_Password('password_new_confirm');
		$passwordsMatch = new Euso_Validate_FieldsMatch('password_new');
		$passwordsMatch->setMessage(_('Passwords do not match'));
		$pwdnew2
			->setLabel('Confirm new password:')
			->setRequired(true)
			->addFilter($stripSlashesFilter)
			->addFilter('StringTrim')
			->addValidator($passwordsMatch)
			->setAttrib('size', 36)
		;
		$this->addElement($pwdnew2);

        // Add the submit button
		$submit = new Zend_Form_Element_Submit('submit');
		$submit
			->setLabel('Submit')
			->setIgnore(true)
			->setAttrib('class', 'submit')
		;
		$this->addElement($submit);
	}
}
